package com.myhexin.service.impl;

import com.myhexin.entity.Table;
import com.myhexin.service.ITableService;
import org.springframework.stereotype.Service;

/**
 * Created by zjh on 2017/3/24.
 */
@Service
public class TableServiceImpl implements ITableService{



    @Override
    public void gatherCard(Table table) {

    }

    @Override
    public void washCard(Table table) {

    }

    @Override
    public void sendCard(Table table) {
        int size = table.getPlayers().size();
        //每人13张牌
        for (int i=0;i<13;i++) {
            for (int j=0;j<size;j++){
                //轮着个玩家发牌
                int playerIndex = (table.getZhuangPlayerIndex() + j) / size;
                Byte pop = table.getCardsInTable().pop();
                table.getPlayers().get(playerIndex).getCardsInHand().add(pop);
            }
        }
        table.setChuPlayerIndex(table.getZhuangPlayerIndex());
        table.setQuanNum(1);
    }


}
